/**
 * 纸槽
 */
PaperSlot = Widget.extend({
	ctor:function(){
		this._super();
		this.init();
		this.setTag(TAG_PAPERSLOT);
	},
	init:function(){
		var slot = new Button(this, 8, TAG_SLOT, "#slot.png", this.callback);
		slot.setScale(0.8);
		
		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callNext.retain();
	},
	absorbBack:function(){

	},
	rotateBody:function(obj){

	},
	callback:function(p){
		switch(p.getTag()){
		case TAG_SLOT:
			var testtube=ll.run.getChildByTag(TAG_TUBE).getChildByTag(TAG_TESTTUBE);
			var move1=cc.moveTo(0.6, cc.p(20,0));
			var move2=cc.moveTo(1,cc.p(-200,0));
			var seq=cc.sequence(cc.callFunc(function() {
				
				var rot1=cc.rotateTo(0.6, 90);
				testtube.runAction(rot1);
			}, this),move1,move2,cc.callFunc(function() {
				var testtube=ll.run.getChildByTag(TAG_TUBE).getChildByTag(TAG_TESTTUBE);
				p.removeFromParent();
				testtube.addChild(p);
				p.setPosition(cc.p(20,166));
				p.setRotation(-90);
				
				var seqqq=cc.sequence(cc.callFunc(function() {
					var fe=testtube.getChildByTag(TAG_SLOT).getChildByTag(TAG_FILTER_FE);					
					fe.retain();
					fe.removeFromParent();
					testtube.addChild(fe,1);				
					fe.setPosition(cc.p(21,34));
					fe.setScale(1,0.5);
					var mo1=cc.moveTo(0.6,cc.p(21,21));
					fe.runAction(cc.sequence(mo1,cc.callFunc(function() {
						fe.release();
					}, this)));
					var s=testtube.getChildByTag(TAG_SLOT).getChildByTag(TAG_FILTER_S);
					s.retain();
					s.removeFromParent();
					testtube.addChild(s,1);
					s.setPosition(cc.p(21,34));
					s.setScale(1,0.5);
					var mo2=cc.moveTo(0.6,cc.p(21,21));
					s.runAction(cc.sequence(mo2,cc.callFunc(function() {
						s.release();
					}, this)));					
				}, this),cc.rotateTo(0.6, 0));
				testtube.runAction(seqqq);				
			}, this),cc.callFunc(function() {
				var move3=cc.moveTo(1, cc.p(20,300));
				var se=cc.sequence(move3,cc.callFunc(function() {
					p.removeFromParent();
					gg.flow.next();
				}, this));
				testtube.getChildByTag(TAG_SLOT).runAction(se);
			}, this));
			p.runAction(seq);
			break;
		}
	},
	actionDone:function(p){
		switch(p.getTag()){
		case TAG_SPOON_SPOON:
			break;
		}
	},
	onExit:function(){
		this._super();
		this.callNext.release();
	}
});